package cn.net.xyan.blossom.kotlin

import org.slf4j.Logger
import org.slf4j.LoggerFactory
import kotlin.properties.ReadOnlyProperty
import kotlin.reflect.KProperty

class LoggerPropertyDelegate<in T : Any> : ReadOnlyProperty<T, Logger> {
    operator override fun getValue(thisRef: T, property: KProperty<*>): Logger {
        val logger = LoggerFactory.getLogger(thisRef.javaClass)
        return logger
    }
}

val <T : Any> T.logger: Logger by LoggerPropertyDelegate()